<?php
namespace app\admin\controller;

use app\common\controller\AdminBase;
use think\Db;

/**
 * 配置
 * Class System
 * @package app\admin\controller
 */
class UsedLinkman extends AdminBase
{
    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 配置
     */
    public function index()
    {
        $used_config = Db::name('used_linkman')->field('value')->where('name', 'used_config')->find();
        $used_config = unserialize($used_config['value']);

        return $this->fetch('used_config', ['used_config' => $used_config]);
    }

    /**
     * 更新配置
     */
    public function updateUsedConfig()
    {
        if ($this->request->isPost()) {
            $used_config                = $this->request->post('used_config/a');
            $data['value']              = serialize($used_config);
            if (Db::name('used_linkman')->where('name', 'used_config')->update($data) !== false) {
                $this->success('提交成功');
            } else {
                $this->error('提交失败');
            }
        }
    }

}